﻿/**
 * User.java 1.0 2007-4-15 上午12:24:36,创建 by yangfan
 */


package org.in4j.bbs.model;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.builder.ToStringBuilder;

/**
 *
 * @author 杨帆
 * @version 1.0 2007-4-15 上午12:24:36,创建
 */
public class User
{
	public static final String GUEST = "guest";

	private Integer id;
	private String name;
	private String password;
	private String email;
	private String nickname;
	private int status;
	private Set<Post> posts = new HashSet<Post>();
	private Set<Topic> topics = new HashSet<Topic>();

	public Set<Post> getPosts()
	{
		return posts;
	}

	public void setPosts(Set<Post> posts)
	{
		this.posts = posts;
	}
	public Set<Topic> getTopics()
	{
		return topics;
	}
	public void setTopics(Set<Topic> topics)
	{
		this.topics = topics;
	}
	public int getStatus()
	{
		return status;
	}
	public void setStatus(int status)
	{
		this.status = status;
	}
	public String getEmail()
	{
		return email;
	}
	public void setEmail(String email)
	{
		this.email = email;
	}
	public Integer getId()
	{
		return id;
	}
	public void setId(Integer id)
	{
		this.id = id;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public String getPassword()
	{
//		System.out.println("getPassword:" + password + ",this==>" + this);
		return password;
	}
	public void setPassword(String password)
	{
//		System.out.println("setPassword:" + password + ",this==>" + this);
		this.password = password;
	}
	@Override
	public String toString()
	{
		return new ToStringBuilder(this).append("id", id).append("name", name).toString();
	}
	public String getNickname()
	{
		return nickname != null?nickname:name;
	}
	public void setNickname(String nickname)
	{
		this.nickname = nickname;
	}

	public boolean isGuest()
	{
		return this.name.equalsIgnoreCase("guest");
	}
}
